//
//  ViewController.m
//  aLi
//
//  Created by 苗钧豪 on 16/8/13.
//  Copyright © 2016年 苗钧豪. All rights reserved.
//

#import "ViewController.h"
#import "One.h"
@interface ViewController ()
@property (nonatomic ,strong) NSMutableArray *Array;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getup];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)getup {
    self.Array = [NSMutableArray array];
    NSURL *url = [NSURL URLWithString:@"http://api.dongting.com/frontpage/frontpage?location=0&version=1470998222737&app=ttpod&v=v9.0.4.2016070616&user_id=0&mid=iPhone8%2C1&f=f320&s=s310&imsi=&hid=&splus=10.0&active=1&net=2&openudid=4bbd8925c4a3991ee51c9cd8b9a8dc5961820764&idfa=2BBAE4F7-2E3B-41AA-AE0C-F91FB2BDC279&utdid=V62kivWPJBYDABK%2FL8gCUnDI&alf=(null)&bundle_id=com.ttpod.music&latitude=(null)&longtitude=(null)&access_token=(null)&vc=9000400"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:(NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:30];
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingMutableLeaves) error:nil];
        NSArray *array = [NSArray array];
        array = dictionary[@"data"];
        for (NSDictionary *dic in array) {
            One *one = [[One alloc]init];
            [one setValuesForKeysWithDictionary:dic];
            [_Array addObject:one];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
